I'm very new with umbraco (and web developement). My goal is to select a data with the alias in a macro.
This code works and display "12345" : <xsl:value-of select="$currentPage/number"/>
But this code doesn't work and display nothing : <xsl:variable name="temp1" select="$currentPage/data[@alias='number']"/><xsl:value-of select="$temp1"/>
You can do that using the name() function, here's a simple example:
<xsl:variable name="yourFieldAlias" select="'number'"/> <!-- or from a macro parameter: <xsl:variable name="yourFieldAlias" select="/macro/yourParam"/> -->
[beginner] Select a data with alias
Hi,
I'm very new with umbraco (and web developement).
My goal is to select a data with the alias in a macro.
This code works and display "12345" : <xsl:value-of select="$currentPage/number"/>
But this code doesn't work and display nothing : <xsl:variable name="temp1" select="$currentPage/data[@alias='number']"/><xsl:value-of select="$temp1"/>
Is there someone who can explain ?
Hi,
The data [@alias='propertyAlias'] syntax is obsolete now. It was the old XML Schema that Umbraco used to use, prior to version 4.5.
There is no need to use this anymore, you instead refer to a property like in your first example ($currentPage/number).
Check out this wiki page for more information and see the other pages/examples on the right: 4.5 XML Schema
Hope this helps,
Tom
Of course it helps Tom. Thank you.
In fact, my goal is to select dynamically a data with the alias ( text macro parameters).
How to do that now ?
Edit : I will try that :
select="$currentPage/* [name() = $myMacroParameter and not(@isDoc)]"/>
You can do that using the name() function, here's a simple example:
That should get you the same result as $currentPage/number
-Tom
Thank you very much Tom. It seems easy now.
is working on a reply...